
 <!DOCTYPE HTML>
<html lang="en">
<head>
  <meta charset="UTF-8">
  
    <title>冈崎汐峰的博客</title>
    <meta name="viewport" content="width=device-width, initial-scale=1,user-scalable=no">
    
    <meta name="author" content="冈崎汐峰">
    

    
    <meta property="og:type" content="website">
<meta property="og:title" content="冈崎汐峰的博客">
<meta property="og:url" content="http://yoursite.com/index.html">
<meta property="og:site_name" content="冈崎汐峰的博客">
<meta property="og:locale" content="en_US">
<meta property="article:author" content="冈崎汐峰">
<meta name="twitter:card" content="summary">

    
    <link rel="alternative" href="/atom.xml" title="冈崎汐峰的博客" type="application/atom+xml">
    
    
    <link rel="icon" href="/img/favicon.ico">
    
    
    <link rel="apple-touch-icon" href="/img/jacman.jpg">
    <link rel="apple-touch-icon-precomposed" href="/img/jacman.jpg">
    
    
<link rel="stylesheet" href="/css/style.css">
<link rel="stylesheet" href="/%02.css">
<link rel="stylesheet" href="/.css">

<meta name="generator" content="Hexo 4.2.0"></head>

  <body>
    <header>
      
<div>
		
			<div id="imglogo">
				<a href="/"><img src="/img/logo.png" alt="冈崎汐峰的博客" title="冈崎汐峰的博客"/></a>
			</div>
			
			<div id="textlogo">
				<h1 class="site-name"><a href="/" title="冈崎汐峰的博客">冈崎汐峰的博客</a></h1>
				<h2 class="blog-motto"></h2>
			</div>
			<div class="navbar"><a class="navbutton navmobile" href="#" title="Menu">
			</a></div>
			<nav class="animated">
				<ul>
					<ul>
					 
						<li><a href="/">Home</a></li>
					
						<li><a href="/archives">Archives</a></li>
					
						<li><a href="/about">About</a></li>
					
					<li>
 					
					<form class="search" action="//google.com/search" method="get" accept-charset="utf-8">
						<label>Search</label>
						<input type="search" id="search" name="q" autocomplete="off" maxlength="20" placeholder="Search" />
						<input type="hidden" name="q" value="site:yoursite.com">
					</form>
					
					</li>
				</ul>
			</nav>			
</div>
    </header>
    <div id="container">
      <div id="main">

   
    
    <article class="post-expand post" itemprop="articleBody"> 
        <header class="article-info clearfix">
  <h1 itemprop="name">
    
      <a href="/2020/06/15/深度学习基础——回归/" title="深度学习基础——回归" itemprop="url">深度学习基础——回归</a>
  </h1>
  <p class="article-author">By
       
		<a href="/about" title="冈崎汐峰" target="_blank" itemprop="author">冈崎汐峰</a>
		
  <p class="article-time">
    <time datetime="2020-06-15T07:20:44.442Z" itemprop="datePublished"> Published 2020-06-15</time>
    
  </p>
</header>
    <div class="article-content">
        
        <h1 id="线性回归分析"><a href="#线性回归分析" class="headerlink" title="线性回归分析"></a>线性回归分析</h1><h3 id="建立线性方程y-wx-b"><a href="#建立线性方程y-wx-b" class="headerlink" title="建立线性方程y = wx + b"></a>建立线性方程y = wx + b</h3><p>再建立误差方程∑（wx + b - y）^2<br>，以梯度下降算法求出w和b的最优解</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> numpy <span class="keyword">as</span> np</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">totalError</span><span class="params">(w_current, b_current, points)</span>:</span></span><br><span class="line">    <span class="string">"""求出当前w和b对应的误差值"""</span></span><br><span class="line">    total_error = <span class="number">0</span></span><br><span class="line">    <span class="keyword">for</span> i <span class="keyword">in</span> range(len(points)):</span><br><span class="line">        x = points[i, <span class="number">0</span>]</span><br><span class="line">        y = points[i, <span class="number">1</span>]</span><br><span class="line">        total_error += (w_current * x + b_current - y)**<span class="number">2</span></span><br><span class="line">    <span class="keyword">return</span> total_error / float(len(points))</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">update</span><span class="params">(w_current, b_current, learnRate, points)</span>:</span></span><br><span class="line">    <span class="string">"""更新b和w的值"""</span></span><br><span class="line">    w_gradient = <span class="number">0</span></span><br><span class="line">    b_gradient = <span class="number">0</span></span><br><span class="line">    N = float(len(points))</span><br><span class="line">    <span class="keyword">for</span> i <span class="keyword">in</span> range(len(points)):</span><br><span class="line">        x = points[i, <span class="number">0</span>]</span><br><span class="line">        y = points[i, <span class="number">1</span>]</span><br><span class="line">        w_gradient += (<span class="number">2</span> / N) * x * (w_current * x + b_current - y)</span><br><span class="line">        b_gradient += (<span class="number">2</span> / N) * (w_current * x + b_current - y)</span><br><span class="line">    new_w = w_current - learnRate * w_gradient</span><br><span class="line">    new_b = b_current - learnRate * b_gradient</span><br><span class="line">    <span class="keyword">return</span> [new_w, new_b]</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">gradient_runner</span><span class="params">(w, b, points, loops, learnRate)</span>:</span></span><br><span class="line">    <span class="string">"""重复更新w和b"""</span></span><br><span class="line">    <span class="keyword">for</span> i <span class="keyword">in</span> range(loops):</span><br><span class="line">        [w, b] = update(w, b, learnRate, points)</span><br><span class="line">    <span class="keyword">return</span> [w, b]</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">run</span><span class="params">()</span>:</span></span><br><span class="line">    points = np.genfromtxt(<span class="string">r"E:\py\tensorflow\ch02-回归问题\data.csv"</span>, delimiter=<span class="string">","</span>)</span><br><span class="line">    learnRate = <span class="number">0.0001</span></span><br><span class="line">    loops = <span class="number">1000</span></span><br><span class="line">    w0 = <span class="number">0</span></span><br><span class="line">    b0 = <span class="number">0</span></span><br><span class="line">    print(<span class="string">"初始情况下，w = &#123;0&#125;, b = &#123;1&#125;, 误差值为&#123;2&#125;"</span>.format(w0, b0, totalError(w0, b0, points)))</span><br><span class="line">    [w, b] = gradient_runner(w0, b0, points, loops, learnRate)</span><br><span class="line">    print(<span class="string">"优化以后，w = &#123;0&#125;, b = &#123;1&#125;, 误差值为&#123;2&#125;"</span>.format(w, b, totalError(w, b, points)))</span><br><span class="line"></span><br><span class="line">run()</span><br></pre></td></tr></table></figure>

        
        
        <p class="article-more-link">
          
       </p>
    </div>
    <footer class="article-footer clearfix">
<div class="article-catetags">


</div>




<div class="comments-count">
	
</div>

</footer>


    </article>






   
    
    <article class="post-expand post" itemprop="articleBody"> 
        <header class="article-info clearfix">
  <h1 itemprop="name">
    
      <a href="/2020/04/04/异常/" title="异常" itemprop="url">异常</a>
  </h1>
  <p class="article-author">By
       
		<a href="/about" title="冈崎汐峰" target="_blank" itemprop="author">冈崎汐峰</a>
		
  <p class="article-time">
    <time datetime="2020-04-04T09:47:22.465Z" itemprop="datePublished"> Published 2020-04-04</time>
    
  </p>
</header>
    <div class="article-content">
        
        <h1 id="异常"><a href="#异常" class="headerlink" title="异常"></a>异常</h1><h2 id="alice"><a href="#alice" class="headerlink" title="alice"></a>alice</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">filename = <span class="string">"alice.txt"</span></span><br><span class="line"><span class="keyword">try</span>:</span><br><span class="line">    <span class="keyword">with</span> open(filename) <span class="keyword">as</span> f_obj:</span><br><span class="line">        cotens = f_obj.read()</span><br><span class="line"><span class="keyword">except</span> FileNotFoundError:</span><br><span class="line">    msg = <span class="string">"Sorry, the file "</span>+filename+<span class="string">" does not exist."</span></span><br><span class="line">    print(msg)</span><br></pre></td></tr></table></figure>
<h2 id="dividion"><a href="#dividion" class="headerlink" title="dividion"></a>dividion</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">print(<span class="string">"Give me two numbers, and I'll divide them."</span>)</span><br><span class="line">print(<span class="string">"Enter 'q' to quit"</span>)</span><br><span class="line"><span class="keyword">while</span> <span class="literal">True</span>:</span><br><span class="line">    first_number = input(<span class="string">"First_name:"</span>)</span><br><span class="line">    <span class="keyword">if</span> first_number == <span class="string">"q"</span>:</span><br><span class="line">        <span class="keyword">break</span></span><br><span class="line">    second_number = input(<span class="string">"Second number:"</span>)</span><br><span class="line">    <span class="keyword">if</span> second_number == <span class="string">"q"</span>:</span><br><span class="line">        <span class="keyword">break</span></span><br><span class="line">    <span class="keyword">try</span>:</span><br><span class="line">        answer = int(first_number) / int(second_number)</span><br><span class="line">    <span class="keyword">except</span> ZeroDivisionError:</span><br><span class="line">        print(<span class="string">"You can't divide by 0!"</span>)</span><br><span class="line">    <span class="keyword">else</span>:</span><br><span class="line">        print(answer)</span><br></pre></td></tr></table></figure>
<h2 id="greet-user"><a href="#greet-user" class="headerlink" title="greet user"></a>greet user</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> json</span><br><span class="line">fliename = <span class="string">"username.json"</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">with</span> open(fliename) <span class="keyword">as</span> f_obj:</span><br><span class="line">    username = json.load(f_obj)</span><br><span class="line">    print(<span class="string">"Welcome back, "</span>+username+<span class="string">"!"</span>)</span><br></pre></td></tr></table></figure>
<h2 id="number-reader"><a href="#number-reader" class="headerlink" title="number reader"></a>number reader</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> json</span><br><span class="line">filename = <span class="string">"number.json"</span></span><br><span class="line"><span class="keyword">with</span> open(filename) <span class="keyword">as</span> f_obj:</span><br><span class="line">    numbers = json.load(f_obj)</span><br><span class="line"></span><br><span class="line">print(numbers)</span><br></pre></td></tr></table></figure>
<h2 id="number-write"><a href="#number-write" class="headerlink" title="number write"></a>number write</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> json</span><br><span class="line"></span><br><span class="line">numbers = [<span class="number">2</span>, <span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">11</span>, <span class="number">13</span>]</span><br><span class="line"></span><br><span class="line">fliename = <span class="string">"number.json"</span></span><br><span class="line"><span class="keyword">with</span> open(fliename,<span class="string">"w"</span>) <span class="keyword">as</span> f_obj:</span><br><span class="line">    json.dump(numbers,f_obj)</span><br></pre></td></tr></table></figure>

        
        
        <p class="article-more-link">
          
       </p>
    </div>
    <footer class="article-footer clearfix">
<div class="article-catetags">


</div>




<div class="comments-count">
	
</div>

</footer>


    </article>






   
    
    <article class="post-expand post" itemprop="articleBody"> 
        <header class="article-info clearfix">
  <h1 itemprop="name">
    
      <a href="/2020/04/04/类/" title="类" itemprop="url">类</a>
  </h1>
  <p class="article-author">By
       
		<a href="/about" title="冈崎汐峰" target="_blank" itemprop="author">冈崎汐峰</a>
		
  <p class="article-time">
    <time datetime="2020-04-04T09:47:22.464Z" itemprop="datePublished"> Published 2020-04-04</time>
    
  </p>
</header>
    <div class="article-content">
        
        <h1 id="类"><a href="#类" class="headerlink" title="类"></a>类</h1><h2 id="car"><a href="#car" class="headerlink" title="car"></a>car</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br></pre></td><td class="code"><pre><span class="line"><span class="string">"""一个可用于表示汽车的类"""</span></span><br><span class="line"></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">Car</span><span class="params">()</span>:</span></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">__init__</span><span class="params">(self,make,model,year)</span>:</span></span><br><span class="line">        <span class="string">"""初始化汽车属性"""</span></span><br><span class="line">        self.make = make</span><br><span class="line">        self.model = model</span><br><span class="line">        self.year = year</span><br><span class="line">        self.odometer_reading = <span class="number">0</span></span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">get_descriptive_name</span><span class="params">(self)</span>:</span></span><br><span class="line">        <span class="string">"""返回整洁的描述性信息"""</span></span><br><span class="line">        long_name = str(self.year)+<span class="string">" "</span>+self.make+<span class="string">" "</span>+self.model</span><br><span class="line">        <span class="keyword">return</span> long_name.title()</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">read_odometer</span><span class="params">(self)</span>:</span></span><br><span class="line">        <span class="string">"""打印一条指出汽车里程的消息"""</span></span><br><span class="line">        print(<span class="string">"This car has "</span>+str(self.odometer_reading)+<span class="string">" miles on it."</span>)</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">update_odometer</span><span class="params">(self,mileage)</span>:</span></span><br><span class="line">        <span class="string">"""</span></span><br><span class="line"><span class="string">        将里程表读数设置为指定的值</span></span><br><span class="line"><span class="string">        禁止将里程表读数往回调</span></span><br><span class="line"><span class="string">        """</span></span><br><span class="line">        <span class="keyword">if</span> mileage &gt;= self.odometer_reading:</span><br><span class="line">            self.odometer_reading = mileage</span><br><span class="line">        <span class="keyword">else</span>:</span><br><span class="line">            print(<span class="string">"You can't roll back an odometer!"</span>)</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">increment_odometer</span><span class="params">(self,miles)</span>:</span></span><br><span class="line">        <span class="string">"""将里程表读数增加指定的量"""</span></span><br><span class="line">        self.odometer_reading += miles</span><br></pre></td></tr></table></figure>
<h2 id="class-car"><a href="#class-car" class="headerlink" title="class car"></a>class car</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br></pre></td><td class="code"><pre><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">Car</span><span class="params">()</span>:</span></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">__init__</span><span class="params">(self,make,model,year)</span>:</span></span><br><span class="line">        <span class="string">"""初始化汽车属性"""</span></span><br><span class="line">        self.make = make</span><br><span class="line">        self.model = model</span><br><span class="line">        self.year = year</span><br><span class="line">        self.odometer_reading = <span class="number">0</span></span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">get_descriptive_name</span><span class="params">(self)</span>:</span></span><br><span class="line">        <span class="string">"""返回整洁的描述性信息"""</span></span><br><span class="line">        long_name = str(self.year)+<span class="string">" "</span>+self.make+<span class="string">" "</span>+self.model</span><br><span class="line">        <span class="keyword">return</span> long_name.title()</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">read_odometer</span><span class="params">(self)</span>:</span></span><br><span class="line">        <span class="string">"""打印一条指出汽车里程的消息"""</span></span><br><span class="line">        print(<span class="string">"This car has "</span>+str(self.odometer_reading)+<span class="string">" miles on it."</span>)</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">update_odometer</span><span class="params">(self,mileage)</span>:</span></span><br><span class="line">        <span class="string">"""</span></span><br><span class="line"><span class="string">        将里程表读数设置为指定的值</span></span><br><span class="line"><span class="string">        禁止将里程表读数往回调</span></span><br><span class="line"><span class="string">        """</span></span><br><span class="line">        <span class="keyword">if</span> mileage &gt;= self.odometer_reading:</span><br><span class="line">            self.odometer_reading = mileage</span><br><span class="line">        <span class="keyword">else</span>:</span><br><span class="line">            print(<span class="string">"You can't roll back an odometer!"</span>)</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">increment_odometer</span><span class="params">(self,miles)</span>:</span></span><br><span class="line">        <span class="string">"""将里程表读数增加指定的量"""</span></span><br><span class="line">        self.odometer_reading += miles</span><br><span class="line"></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">Battery</span><span class="params">()</span>:</span></span><br><span class="line">    <span class="string">"""一次模拟电动汽车电瓶的简单尝试"""</span></span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">__init__</span><span class="params">(self,battery_size=<span class="number">70</span>)</span>:</span></span><br><span class="line">        <span class="string">"""初始化电瓶的属性"""</span></span><br><span class="line">        self.battery_size = battery_size</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">describle_battery</span><span class="params">(self)</span>:</span></span><br><span class="line">        <span class="string">"""打印一条描述电瓶容量的消息"""</span></span><br><span class="line">        print(<span class="string">"this car has a "</span>+str(self.battery_size)+<span class="string">"-kwh battery"</span>)</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">get_range</span><span class="params">(self)</span>:</span></span><br><span class="line">        <span class="string">"""打印一条消息，指出电瓶的续航里程"""</span></span><br><span class="line">        <span class="keyword">if</span> self.battery_size == <span class="number">70</span>:</span><br><span class="line">            range = <span class="number">240</span></span><br><span class="line">        <span class="keyword">elif</span> self.battery_size == <span class="number">85</span>:</span><br><span class="line">            range = <span class="number">270</span></span><br><span class="line"></span><br><span class="line">        message = <span class="string">"This car can go approximately "</span>+str(range)</span><br><span class="line">        message += <span class="string">" miles on a full charge."</span></span><br><span class="line">        print(message)</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">ElectrocCar</span><span class="params">(Car)</span>:</span></span><br><span class="line">    <span class="string">"""电动汽车的独特之处"""</span></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">__init__</span><span class="params">(self,make,model,year)</span>:</span></span><br><span class="line">        <span class="string">"""</span></span><br><span class="line"><span class="string">        电动汽车的独特之处</span></span><br><span class="line"><span class="string">        初始化父类的属性，在初始化电动汽车特有的属性</span></span><br><span class="line"><span class="string">        """</span></span><br><span class="line">        super().__init__(make,model,year)</span><br><span class="line">        self.battery = Battery()</span><br><span class="line"></span><br><span class="line">    </span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">my_tesla = ElectrocCar(<span class="string">"tesla"</span>,<span class="string">"model s"</span>,<span class="number">2016</span>)</span><br><span class="line">print(my_tesla.get_descriptive_name())</span><br><span class="line">my_tesla.battery.get_range()</span><br><span class="line"></span><br><span class="line"><span class="string">"""</span></span><br><span class="line"><span class="string">my_new_cat = Car("audi","a4",2016)</span></span><br><span class="line"><span class="string">print(my_new_cat.get_descriptive_name())</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">my_new_cat.update_odometer(23500)</span></span><br><span class="line"><span class="string">my_new_cat.read_odometer()</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">my_new_cat.increment_odometer(100)</span></span><br><span class="line"><span class="string">my_new_cat.read_odometer()</span></span><br><span class="line"><span class="string">"""</span></span><br></pre></td></tr></table></figure>
<h2 id="class-user"><a href="#class-user" class="headerlink" title="class user"></a>class user</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br></pre></td><td class="code"><pre><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">User</span><span class="params">()</span>:</span></span><br><span class="line">    <span class="string">"""创建一个User类"""</span></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">__init__</span><span class="params">(self,first_name,last_name,login_attempts)</span>:</span></span><br><span class="line">        <span class="string">"""初始化User的属性"""</span></span><br><span class="line">        self.first = first_name</span><br><span class="line">        self.last = last_name</span><br><span class="line">        self.login_attempts = login_attempts</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">describe_user</span><span class="params">(self)</span>:</span></span><br><span class="line">        <span class="string">"""描述User的姓名"""</span></span><br><span class="line">        self.full_name = self.first.title()+self.last.title()</span><br><span class="line">        print(self.full_name)</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">greet_user</span><span class="params">(self)</span>:</span></span><br><span class="line">        <span class="string">"""打招呼"""</span></span><br><span class="line">        print(<span class="string">"Hello "</span>+self.full_name)</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">increment_login_attemptes</span><span class="params">(self)</span>:</span></span><br><span class="line">        <span class="string">"""对User的login_attempts属性每次加1"""</span></span><br><span class="line">        self.login_attempts += <span class="number">1</span></span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">reset_login_attemptes</span><span class="params">(self)</span>:</span></span><br><span class="line">        <span class="string">"""清零login_attempts"""</span></span><br><span class="line">        self.login_attempts = <span class="number">0</span></span><br><span class="line"></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">Privileges</span><span class="params">()</span>:</span></span><br><span class="line">    <span class="string">"""创建Privileges类"""</span></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">__init__</span><span class="params">(self,priviliges = [<span class="string">"can add post"</span>,<span class="string">"can de;ete post"</span>,<span class="string">"can ban user"</span>])</span>:</span></span><br><span class="line">        <span class="string">"""初始化特权属性"""</span></span><br><span class="line">        self.privileges = priviliges</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">Admin</span><span class="params">(User)</span>:</span></span><br><span class="line">    <span class="string">"""创建User的子类：管理员"""</span></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">__init__</span><span class="params">(self,first_name, last_name, login_attempts)</span>:</span></span><br><span class="line">        <span class="string">"""初始化父类和子类的属性"""</span></span><br><span class="line">        super().__init__(first_name, last_name, login_attempts)</span><br><span class="line">        self.privilege = Privileges()</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">show_privilleges</span><span class="params">(self)</span>:</span></span><br><span class="line">        <span class="string">"""打印特权属性"""</span></span><br><span class="line">        print(<span class="string">"Admin has the following privileges:"</span>)</span><br><span class="line">        <span class="keyword">for</span> privilege <span class="keyword">in</span> self.privilege.privileges:</span><br><span class="line">            print(privilege)</span><br><span class="line"></span><br><span class="line">admin = Admin(<span class="string">"zhang"</span>,<span class="string">"san"</span>,<span class="number">10</span>)</span><br><span class="line">admin.show_privilleges()</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="string">"""</span></span><br><span class="line"><span class="string">user = User("zhang","san",10)</span></span><br><span class="line"><span class="string">user.increment_login_attemptes()</span></span><br><span class="line"><span class="string">print(user.login_attempts)</span></span><br><span class="line"><span class="string">user.increment_login_attemptes()</span></span><br><span class="line"><span class="string">print(user.login_attempts)</span></span><br><span class="line"><span class="string">user.increment_login_attemptes()</span></span><br><span class="line"><span class="string">print(user.login_attempts)</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">user.reset_login_attemptes()</span></span><br><span class="line"><span class="string">print(user.login_attempts)</span></span><br><span class="line"><span class="string">"""</span></span><br></pre></td></tr></table></figure>
<h2 id="class-restaurant"><a href="#class-restaurant" class="headerlink" title="class restaurant"></a>class restaurant</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br></pre></td><td class="code"><pre><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">Restaurant</span><span class="params">()</span>:</span></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">__init__</span><span class="params">(self,restaurant_name,cuisine_type)</span>:</span></span><br><span class="line">        self.restaurant_name = restaurant_name</span><br><span class="line">        self.cuisine_type = cuisine_type</span><br><span class="line">        self.num_served = <span class="number">0</span></span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">describle_reataurant</span><span class="params">(self)</span>:</span></span><br><span class="line">        print(<span class="string">"The restaurant's name is "</span>+self.restaurant_name.title())</span><br><span class="line">        print(<span class="string">"THe cuisine type of restaurant is "</span>+self.cuisine_type)</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">open_reatuarent</span><span class="params">(self)</span>:</span></span><br><span class="line">        print(self.restaurant_name+<span class="string">" is opening!"</span>)</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">increment_number_served</span><span class="params">(self,increment_number)</span>:</span></span><br><span class="line">        self.num_served += increment_number</span><br><span class="line"><span class="string">"""</span></span><br><span class="line"><span class="string">class IceCreamStand(Restaurant):</span></span><br><span class="line"><span class="string">    def __init__(self,restaurant_name,cuisine_type):</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">        super().__init__(restaurant_name,cuisine_type)</span></span><br><span class="line"><span class="string">        self.flavors = ["pingguo","xiangjiao","li"]</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">    def print(self):</span></span><br><span class="line"><span class="string">        print("冰激淋的口味有：")</span></span><br><span class="line"><span class="string">        for flavor in self.flavors:</span></span><br><span class="line"><span class="string">            print(flavor)</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">ice_cream_stand = IceCreamStand("dingxiang","bingjilin")</span></span><br><span class="line"><span class="string">ice_cream_stand.print()</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">"""</span></span><br></pre></td></tr></table></figure>
<h2 id="electric-cay"><a href="#electric-cay" class="headerlink" title="electric cay"></a>electric cay</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">from</span> car <span class="keyword">import</span> Car</span><br><span class="line"></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">Battery</span><span class="params">()</span>:</span></span><br><span class="line">    <span class="string">"""一次模拟电动汽车电瓶的简单尝试"""</span></span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">__init__</span><span class="params">(self,battery_size=<span class="number">70</span>)</span>:</span></span><br><span class="line">        <span class="string">"""初始化电瓶的属性"""</span></span><br><span class="line">        self.battery_size = battery_size</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">describle_battery</span><span class="params">(self)</span>:</span></span><br><span class="line">        <span class="string">"""打印一条描述电瓶容量的消息"""</span></span><br><span class="line">        print(<span class="string">"this car has a "</span>+str(self.battery_size)+<span class="string">"-kwh battery"</span>)</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">get_range</span><span class="params">(self)</span>:</span></span><br><span class="line">        <span class="string">"""打印一条消息，指出电瓶的续航里程"""</span></span><br><span class="line">        <span class="keyword">if</span> self.battery_size == <span class="number">70</span>:</span><br><span class="line">            range = <span class="number">240</span></span><br><span class="line">        <span class="keyword">elif</span> self.battery_size == <span class="number">85</span>:</span><br><span class="line">            range = <span class="number">270</span></span><br><span class="line"></span><br><span class="line">        message = <span class="string">"This car can go approximately "</span>+str(range)</span><br><span class="line">        message += <span class="string">" miles on a full charge."</span></span><br><span class="line">        print(message)</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">ElectrocCar</span><span class="params">(Car)</span>:</span></span><br><span class="line">    <span class="string">"""电动汽车的独特之处"""</span></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">__init__</span><span class="params">(self,make,model,year)</span>:</span></span><br><span class="line">        <span class="string">"""</span></span><br><span class="line"><span class="string">        电动汽车的独特之处</span></span><br><span class="line"><span class="string">        初始化父类的属性，在初始化电动汽车特有的属性</span></span><br><span class="line"><span class="string">        """</span></span><br><span class="line">        super().__init__(make,model,year)</span><br><span class="line">        self.battery = Battery()</span><br></pre></td></tr></table></figure>
<h2 id="my-car"><a href="#my-car" class="headerlink" title="my car"></a>my car</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">from</span> car <span class="keyword">import</span> Car</span><br><span class="line"><span class="keyword">from</span> electric_car <span class="keyword">import</span> ElectrocCar</span><br><span class="line"></span><br><span class="line">mt_beetle = Car(<span class="string">"volkswagen"</span>,<span class="string">"beetle"</span>,<span class="number">2016</span>)</span><br><span class="line">print(mt_beetle.get_descriptive_name())</span><br><span class="line"></span><br><span class="line">my_tesla = ElectrocCar(<span class="string">"tesla"</span>,<span class="string">"roadster"</span>,<span class="number">2016</span>)</span><br><span class="line">print(my_tesla.get_descriptive_name())</span><br></pre></td></tr></table></figure>
<h2 id="my-electric-car"><a href="#my-electric-car" class="headerlink" title="my electric car"></a>my electric car</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> car</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">my_bettle = car.Car(<span class="string">"volkawagen"</span>,<span class="string">"bettle"</span>,<span class="number">2016</span>)</span><br><span class="line">print(my_bettle.get_descriptive_name())</span><br><span class="line"></span><br><span class="line">my_tesla =  car.ElectrocCar(<span class="string">"tesla"</span>,<span class="string">"roadster"</span>,<span class="number">2016</span>)</span><br><span class="line">print(my_tesla.get_descriptive_name())</span><br></pre></td></tr></table></figure>

        
        
        <p class="article-more-link">
          
       </p>
    </div>
    <footer class="article-footer clearfix">
<div class="article-catetags">


</div>




<div class="comments-count">
	
</div>

</footer>


    </article>






   
    
    <article class="post-expand post" itemprop="articleBody"> 
        <header class="article-info clearfix">
  <h1 itemprop="name">
    
      <a href="/2020/04/04/测试代码/" title="测试代码" itemprop="url">测试代码</a>
  </h1>
  <p class="article-author">By
       
		<a href="/about" title="冈崎汐峰" target="_blank" itemprop="author">冈崎汐峰</a>
		
  <p class="article-time">
    <time datetime="2020-04-04T09:47:22.462Z" itemprop="datePublished"> Published 2020-04-04</time>
    
  </p>
</header>
    <div class="article-content">
        
        <h1 id="测试代码"><a href="#测试代码" class="headerlink" title="测试代码"></a>测试代码</h1><h2 id="language-survey"><a href="#language-survey" class="headerlink" title="language survey"></a>language survey</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">from</span> survey <span class="keyword">import</span> AnonymousSurvey</span><br><span class="line"></span><br><span class="line"><span class="comment">#定义一个问题，并创建一个表示调查的AnonymousSurvey对象</span></span><br><span class="line">question = <span class="string">"What language did you first learn to speak?"</span></span><br><span class="line">my_survey = AnonymousSurvey(question)</span><br><span class="line"></span><br><span class="line"><span class="comment">#显示问题并存储答案</span></span><br><span class="line">my_survey.show_question()</span><br><span class="line">print(<span class="string">"Enter 'q' at any time to quit.\n"</span>)</span><br><span class="line"><span class="keyword">while</span> <span class="literal">True</span>:</span><br><span class="line">    response = input(<span class="string">"language:"</span>)</span><br><span class="line">    <span class="keyword">if</span> response == <span class="string">"q"</span>:</span><br><span class="line">        <span class="keyword">break</span></span><br><span class="line">    my_survey.store_response(response)</span><br><span class="line"></span><br><span class="line"><span class="comment">#显示调查结果</span></span><br><span class="line">print(<span class="string">"Thank you to everyone who participated in the survey!"</span>)</span><br><span class="line">my_survey.show_results()</span><br></pre></td></tr></table></figure>
<h2 id="name"><a href="#name" class="headerlink" title="name"></a>name</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">from</span> name_function <span class="keyword">import</span> get_formatted_name</span><br><span class="line">print(<span class="string">"Enter 'q' at any time to quit."</span>)</span><br><span class="line"><span class="keyword">while</span> <span class="literal">True</span>:</span><br><span class="line">    first = input(<span class="string">"please give me a first name:"</span>)</span><br><span class="line">    <span class="keyword">if</span> first == <span class="string">"q"</span>:</span><br><span class="line">        <span class="keyword">break</span></span><br><span class="line">    last = input(<span class="string">"please give me a last name:"</span>)</span><br><span class="line">    <span class="keyword">if</span> last == <span class="string">"q"</span>:</span><br><span class="line">        <span class="keyword">break</span></span><br><span class="line"></span><br><span class="line">    formatted_name = get_formatted_name(first,last)</span><br><span class="line">    print(<span class="string">"Neatly formatted name: "</span>+formatted_name+<span class="string">"."</span>)</span><br></pre></td></tr></table></figure>
<h2 id="name-funcition"><a href="#name-funcition" class="headerlink" title="name funcition"></a>name funcition</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">get_formatted_name</span><span class="params">(first, last,middle=<span class="string">""</span> )</span>:</span></span><br><span class="line">    full_name = first+<span class="string">" "</span>+middle+<span class="string">" "</span>+last</span><br><span class="line">    <span class="keyword">return</span> full_name.title()</span><br><span class="line"></span><br><span class="line">formatted_name = get_formatted_name(<span class="string">"janis"</span>,<span class="string">"joplin"</span>)</span><br><span class="line">print(formatted_name)</span><br></pre></td></tr></table></figure>
<h2 id="survey"><a href="#survey" class="headerlink" title="survey"></a>survey</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">AnonymousSurvey</span><span class="params">()</span>:</span></span><br><span class="line">    <span class="string">"""收集匿名调查问卷的答案"""</span></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">__init__</span><span class="params">(self,question)</span>:</span></span><br><span class="line">        self.question = question</span><br><span class="line">        self.responds = []</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">show_question</span><span class="params">(self)</span>:</span></span><br><span class="line">        <span class="string">"""显示调查问卷"""</span></span><br><span class="line">        print(self.question)</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">store_response</span><span class="params">(self,new_response)</span>:</span></span><br><span class="line">        <span class="string">"""存储单份调查答卷"""</span></span><br><span class="line">        self.responds.append(new_response)</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">show_results</span><span class="params">(self)</span>:</span></span><br><span class="line">        <span class="string">"""显示收集到的所有答案"""</span></span><br><span class="line">        print(<span class="string">"Survey results:"</span>)</span><br><span class="line">        <span class="keyword">for</span> response <span class="keyword">in</span> self.responds:</span><br><span class="line">            print(<span class="string">"- "</span>+response)</span><br></pre></td></tr></table></figure>

        
        
        <p class="article-more-link">
          
       </p>
    </div>
    <footer class="article-footer clearfix">
<div class="article-catetags">


</div>




<div class="comments-count">
	
</div>

</footer>


    </article>






   
    
    <article class="post-expand post" itemprop="articleBody"> 
        <header class="article-info clearfix">
  <h1 itemprop="name">
    
      <a href="/2020/04/04/外星人入侵/" title="外星人入侵" itemprop="url">外星人入侵</a>
  </h1>
  <p class="article-author">By
       
		<a href="/about" title="冈崎汐峰" target="_blank" itemprop="author">冈崎汐峰</a>
		
  <p class="article-time">
    <time datetime="2020-04-04T09:32:41.184Z" itemprop="datePublished"> Published 2020-04-04</time>
    
  </p>
</header>
    <div class="article-content">
        
        <h1 id="外星人入侵（未完成）"><a href="#外星人入侵（未完成）" class="headerlink" title="外星人入侵（未完成）"></a>外星人入侵（未完成）</h1><p>因初次接触面向对象的编程语言，学习并不深刻，无法继续进行，我将在以后更加努力学习，从而完成这个项目</p>
<h2 id="alien-invasion"><a href="#alien-invasion" class="headerlink" title="alien_invasion"></a>alien_invasion</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> pygame</span><br><span class="line"></span><br><span class="line"><span class="keyword">from</span> settings <span class="keyword">import</span> Settings</span><br><span class="line"><span class="keyword">from</span> ship <span class="keyword">import</span> Ship</span><br><span class="line"><span class="keyword">import</span> game_functions <span class="keyword">as</span> gf</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">run_game</span><span class="params">()</span>:</span></span><br><span class="line">    <span class="comment"># 初始化游戏并创建一个屏幕对象</span></span><br><span class="line">    pygame.init()</span><br><span class="line">    ai_settings = Settings()</span><br><span class="line">    screen = pygame.display.set_mode(</span><br><span class="line">        (ai_settings.screen_width, ai_settings.screen_height)</span><br><span class="line">    )</span><br><span class="line">    pygame.display.set_caption(<span class="string">"Alien Invasion"</span>)</span><br><span class="line"></span><br><span class="line">    <span class="comment"># 创建一艘飞船</span></span><br><span class="line">    ship = Ship(ai_settings,screen)</span><br><span class="line"></span><br><span class="line">    <span class="comment"># 开始游戏的主循环</span></span><br><span class="line">    <span class="keyword">while</span> <span class="literal">True</span>:</span><br><span class="line">        gf.check_events(ship)</span><br><span class="line">        ship.update()</span><br><span class="line">        gf.update_screen(ai_settings,screen,ship)</span><br><span class="line"></span><br><span class="line">run_game()</span><br></pre></td></tr></table></figure>

<h2 id="game-functions"><a href="#game-functions" class="headerlink" title="game_functions"></a>game_functions</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> sys</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> pygame</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">check_keydown_events</span><span class="params">(event,ship)</span>:</span></span><br><span class="line">    <span class="string">"""响应按键"""</span></span><br><span class="line">    <span class="keyword">if</span> event.key == pygame.K_RIGHT:</span><br><span class="line">        ship.moving_right = <span class="literal">True</span></span><br><span class="line">    <span class="keyword">elif</span> event.key == pygame.K_LEFT:</span><br><span class="line">        ship.moving_left = <span class="literal">True</span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">check_keyup_events</span><span class="params">(event,ship)</span>:</span></span><br><span class="line">    <span class="string">"""响应松开"""</span></span><br><span class="line">    <span class="keyword">if</span> event.key == pygame.K_RIGHT:</span><br><span class="line">        ship.moving_right = <span class="literal">False</span></span><br><span class="line">    <span class="keyword">elif</span> event.key == pygame.K_LEFT:</span><br><span class="line">        ship.moving_left = <span class="literal">False</span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">check_events</span><span class="params">(ship)</span>:</span></span><br><span class="line">    <span class="string">"""响应按键和鼠标事件"""</span></span><br><span class="line">    <span class="keyword">for</span> event <span class="keyword">in</span> pygame.event.get():</span><br><span class="line">        <span class="keyword">if</span> event.type == pygame.QUIT:</span><br><span class="line">            sys.exit()</span><br><span class="line">        <span class="keyword">elif</span> event.type == pygame.KEYDOWN:</span><br><span class="line">            check_keydown_events(event,ship)</span><br><span class="line">        <span class="keyword">elif</span> event.type ==pygame.KEYUP:</span><br><span class="line">            check_keyup_events(event,ship)</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">update_screen</span><span class="params">(ai_settings,screen,ship)</span>:</span></span><br><span class="line">    <span class="string">"""更新屏幕上的图像，并切换到新屏幕"""</span></span><br><span class="line">    <span class="comment"># 每次循环都重新绘制屏幕</span></span><br><span class="line">    screen.fill(ai_settings.bg_color)</span><br><span class="line">    ship.blitme()</span><br><span class="line"></span><br><span class="line">    <span class="comment"># 让最近绘制的屏幕可见</span></span><br><span class="line">    pygame.display.flip()</span><br></pre></td></tr></table></figure>
<h2 id="settings"><a href="#settings" class="headerlink" title="settings"></a>settings</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">Settings</span><span class="params">()</span>:</span></span><br><span class="line">    <span class="string">"""存储《外星人入侵》的所有设置的类"""</span></span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">__init__</span><span class="params">(self)</span>:</span></span><br><span class="line">        <span class="string">"""初始化游戏的设置"""</span></span><br><span class="line">        <span class="comment"># 屏幕设置</span></span><br><span class="line">        self.screen_width = <span class="number">1200</span></span><br><span class="line">        self.screen_height = <span class="number">800</span></span><br><span class="line">        self.bg_color = (<span class="number">230</span>,<span class="number">230</span>,<span class="number">230</span>)</span><br><span class="line">        <span class="comment"># 飞船的设置</span></span><br><span class="line">        self.ship_speed_factor = <span class="number">1.5</span></span><br><span class="line">        <span class="comment"># 子弹设置</span></span><br><span class="line">        self.bullet_speed_factor = <span class="number">1</span></span><br><span class="line">        self.bullet_width = <span class="number">3</span></span><br><span class="line">        self.bullet_height = <span class="number">15</span></span><br><span class="line">        self.bullet_color = <span class="number">60</span>,<span class="number">60</span>,<span class="number">60</span></span><br></pre></td></tr></table></figure>
<h2 id="ship"><a href="#ship" class="headerlink" title="ship"></a>ship</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> pygame</span><br><span class="line"></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">Ship</span><span class="params">()</span>:</span></span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">__init__</span><span class="params">(self,ai_settings,screen)</span>:</span></span><br><span class="line">        <span class="string">"""初始化飞船并设置其初始位置"""</span></span><br><span class="line">        self.screen = screen</span><br><span class="line">        self.ai_settings = ai_settings</span><br><span class="line">        <span class="comment"># 加载飞船图像并获取其外接矩形</span></span><br><span class="line">        self.image = pygame.image.load(<span class="string">r"E:\py\外星人入侵\images\ship.bmp"</span>)</span><br><span class="line">        self.rect = self.image.get_rect()</span><br><span class="line">        self.screen_rect = screen.get_rect()</span><br><span class="line"></span><br><span class="line">        <span class="comment"># 将每一艘新飞船放在屏幕底部中央</span></span><br><span class="line">        self.rect.centerx = self.screen_rect.centerx</span><br><span class="line">        self.rect.bottom = self.screen_rect.bottom</span><br><span class="line"></span><br><span class="line">        <span class="comment"># 在飞船的属性center中存储小数值</span></span><br><span class="line">        self.center = float(self.rect.centerx)</span><br><span class="line"></span><br><span class="line">        <span class="comment"># 移动标志</span></span><br><span class="line">        self.moving_right = <span class="literal">False</span></span><br><span class="line">        self.moving_left = <span class="literal">False</span></span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">update</span><span class="params">(self)</span>:</span></span><br><span class="line">        <span class="string">"""根据移动标志调整飞船的位置"""</span></span><br><span class="line">        <span class="comment"># 更新飞船center的值，而不是rect</span></span><br><span class="line">        <span class="keyword">if</span> self.moving_right <span class="keyword">and</span> self.rect.right &lt; self.screen_rect.right:</span><br><span class="line">            self.center += self.ai_settings.ship_speed_factor</span><br><span class="line">        <span class="keyword">if</span> self.moving_left <span class="keyword">and</span> self.rect.left &gt; <span class="number">0</span>:</span><br><span class="line">            self.center -= self.ai_settings.ship_speed_factor</span><br><span class="line"></span><br><span class="line">        <span class="comment"># 根据self.center更新rect对象</span></span><br><span class="line">        self.rect.centerx = self.center</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">blitme</span><span class="params">(self)</span>:</span></span><br><span class="line">        <span class="string">"""在指定位置绘制飞船"""</span></span><br><span class="line">        self.screen.blit(self.image,self.rect)</span><br></pre></td></tr></table></figure>
<h2 id="bullet"><a href="#bullet" class="headerlink" title="bullet"></a>bullet</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> pygame</span><br><span class="line"><span class="keyword">from</span> pygame.sprite <span class="keyword">import</span> Sprite</span><br><span class="line"></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">Bullet</span><span class="params">(Sprite)</span>:</span></span><br><span class="line">    <span class="string">"""一个对飞船发射的子弹进行管理的类"""</span></span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">__init__</span><span class="params">(self,ai_settings,screen,ship)</span>:</span></span><br><span class="line">        <span class="string">"""在飞船所处的位置创建一个子弹对象"""</span></span><br><span class="line">        super(Bullet,self).__init__()</span><br><span class="line">        self.screen = screen</span><br><span class="line"></span><br><span class="line">        <span class="comment"># 在(0,0)处创建一个表示子弹的矩形，再设置正确的位置</span></span><br><span class="line">        self.rect = pygame.Rect(<span class="number">0</span>,<span class="number">0</span>,ai_settings.bullet_width,ai_settings.bullet_height)</span><br><span class="line">        self.rect.centerx = ship.rect.centerx</span><br><span class="line">        self.rect.top = ship.rect.top</span><br><span class="line">        <span class="comment"># 存储用小数表示的子弹位置</span></span><br><span class="line">        self.y = float(self.rect.y)</span><br><span class="line"></span><br><span class="line">        self.color = ai_settings.bullet_color</span><br><span class="line">        self.speed_factor = ai_settings.bullet_speed_factor</span><br></pre></td></tr></table></figure>

        
        
        <p class="article-more-link">
          
       </p>
    </div>
    <footer class="article-footer clearfix">
<div class="article-catetags">


</div>




<div class="comments-count">
	
</div>

</footer>


    </article>






   
    
    <article class="post-expand post" itemprop="articleBody"> 
        <header class="article-info clearfix">
  <h1 itemprop="name">
    
      <a href="/2020/03/28/第一个博客/" title="第一个博客" itemprop="url">第一个博客</a>
  </h1>
  <p class="article-author">By
       
		<a href="/about" title="冈崎汐峰" target="_blank" itemprop="author">冈崎汐峰</a>
		
  <p class="article-time">
    <time datetime="2020-03-28T08:34:47.544Z" itemprop="datePublished"> Published 2020-03-28</time>
    
  </p>
</header>
    <div class="article-content">
        
        <h1 id="标题"><a href="#标题" class="headerlink" title="标题"></a>标题</h1><h2 id="第一章"><a href="#第一章" class="headerlink" title="第一章"></a>第一章</h2><p>```python<br>   print(“Hello World”)</p>

        
        
        <p class="article-more-link">
          
       </p>
    </div>
    <footer class="article-footer clearfix">
<div class="article-catetags">


</div>




<div class="comments-count">
	
</div>

</footer>


    </article>






   
    
    <article class="post-expand post" itemprop="articleBody"> 
        <header class="article-info clearfix">
  <h1 itemprop="name">
    
      <a href="/2020/03/28/hello-world/" title="Hello World" itemprop="url">Hello World</a>
  </h1>
  <p class="article-author">By
       
		<a href="/about" title="冈崎汐峰" target="_blank" itemprop="author">冈崎汐峰</a>
		
  <p class="article-time">
    <time datetime="2020-03-28T08:15:55.468Z" itemprop="datePublished"> Published 2020-03-28</time>
    
  </p>
</header>
    <div class="article-content">
        
        <p>Welcome to <a href="https://hexo.io/" target="_blank" rel="noopener">Hexo</a>! This is your very first post. Check <a href="https://hexo.io/docs/" target="_blank" rel="noopener">documentation</a> for more info. If you get any problems when using Hexo, you can find the answer in <a href="https://hexo.io/docs/troubleshooting.html" target="_blank" rel="noopener">troubleshooting</a> or you can ask me on <a href="https://github.com/hexojs/hexo/issues" target="_blank" rel="noopener">GitHub</a>.</p>
<h2 id="Quick-Start"><a href="#Quick-Start" class="headerlink" title="Quick Start"></a>Quick Start</h2><h3 id="Create-a-new-post"><a href="#Create-a-new-post" class="headerlink" title="Create a new post"></a>Create a new post</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo new <span class="string">"My New Post"</span></span><br></pre></td></tr></table></figure>

<p>More info: <a href="https://hexo.io/docs/writing.html" target="_blank" rel="noopener">Writing</a></p>
<h3 id="Run-server"><a href="#Run-server" class="headerlink" title="Run server"></a>Run server</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo server</span><br></pre></td></tr></table></figure>

<p>More info: <a href="https://hexo.io/docs/server.html" target="_blank" rel="noopener">Server</a></p>
<h3 id="Generate-static-files"><a href="#Generate-static-files" class="headerlink" title="Generate static files"></a>Generate static files</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo generate</span><br></pre></td></tr></table></figure>

<p>More info: <a href="https://hexo.io/docs/generating.html" target="_blank" rel="noopener">Generating</a></p>
<h3 id="Deploy-to-remote-sites"><a href="#Deploy-to-remote-sites" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo deploy</span><br></pre></td></tr></table></figure>

<p>More info: <a href="https://hexo.io/docs/one-command-deployment.html" target="_blank" rel="noopener">Deployment</a></p>

        
        
        <p class="article-more-link">
          
       </p>
    </div>
    <footer class="article-footer clearfix">
<div class="article-catetags">


</div>




<div class="comments-count">
	
</div>

</footer>


    </article>







</div>
      <div class="openaside"><a class="navbutton" href="#" title="Show Sidebar"></a></div>

<div id="asidepart">
<div class="closeaside"><a class="closebutton" href="#" title="Hide Sidebar"></a></div>
<aside class="clearfix">

  


  

  

  <div class="linkslist">
  <p class="asidetitle">Links</p>
    <ul>
        
          <li>
            
            	<a href="https://coderq.com" target="_blank" title="一个面向程序员交流分享的新一代社区">码农圈</a>
            
          </li>
        
          <li>
            
            	<a href="http://wuchong.me" target="_blank" title="Jark&#39;s Blog">Jark&#39;s Blog</a>
            
          </li>
        
    </ul>
</div>

  


  <div class="rsspart">
	<a href="/atom.xml" target="_blank" title="rss">RSS</a>
</div>

  <div class="weiboshow">
  <p class="asidetitle">Weibo</p>
    <iframe width="100%" height="119" class="share_self"  frameborder="0" scrolling="no" src="http://widget.weibo.com/weiboshow/index.php?language=&width=0&height=119&fansRow=2&ptype=1&speed=0&skin=9&isTitle=1&noborder=1&isWeibo=0&isFans=0&uid=&verifier=b3593ceb&dpc=1"></iframe>
</div>


</aside>
</div>
    </div>
    <footer><div id="footer" >
	
	<div class="line">
		<span></span>
		<div class="author"></div>
	</div>
	
	
	<section class="info">
		<p> Hello ,I&#39;m Larry Page in Google. <br/>
			This is my blog,believe it or not.</p>
	</section>
	 
	<div class="social-font" class="clearfix">
		
		<a href="http://weibo.com/2176287895" target="_blank" class="icon-weibo" title="微博"></a>
		
		
		
		
		
		
		
		
		
		
	</div>
			
		

		<p class="copyright">
		Powered by <a href="http://hexo.io" target="_blank" title="hexo">hexo</a> and Theme by <a href="https://github.com/wuchong/jacman" target="_blank" title="Jacman">Jacman</a> © 2020 
		
		<a href="/about" target="_blank" title="冈崎汐峰">冈崎汐峰</a>
		
		
		</p>
</div>
</footer>
    <script src="/js/jquery-2.0.3.min.js"></script>
<script src="/js/jquery.imagesloaded.min.js"></script>
<script src="/js/gallery.js"></script>
<script src="/js/jquery.qrcode-0.12.0.min.js"></script>

<script type="text/javascript">
$(document).ready(function(){ 
  $('.navbar').click(function(){
    $('header nav').toggleClass('shownav');
  });
  var myWidth = 0;
  function getSize(){
    if( typeof( window.innerWidth ) == 'number' ) {
      myWidth = window.innerWidth;
    } else if( document.documentElement && document.documentElement.clientWidth) {
      myWidth = document.documentElement.clientWidth;
    };
  };
  var m = $('#main'),
      a = $('#asidepart'),
      c = $('.closeaside'),
      o = $('.openaside');
  c.click(function(){
    a.addClass('fadeOut').css('display', 'none');
    o.css('display', 'block').addClass('fadeIn');
    m.addClass('moveMain');
  });
  o.click(function(){
    o.css('display', 'none').removeClass('beforeFadeIn');
    a.css('display', 'block').removeClass('fadeOut').addClass('fadeIn');      
    m.removeClass('moveMain');
  });
  $(window).scroll(function(){
    o.css("top",Math.max(80,260-$(this).scrollTop()));
  });
  
  $(window).resize(function(){
    getSize(); 
    if (myWidth >= 1024) {
      $('header nav').removeClass('shownav');
    }else{
      m.removeClass('moveMain');
      a.css('display', 'block').removeClass('fadeOut');
      o.css('display', 'none');
        
    }
  });
});
</script>












<link rel="stylesheet" href="/fancybox/jquery.fancybox.css" media="screen" type="text/css">
<script src="/fancybox/jquery.fancybox.pack.js"></script>
<script type="text/javascript">
$(document).ready(function(){ 
  $('.article-content').each(function(i){
    $(this).find('img').each(function(){
      if ($(this).parent().hasClass('fancybox')) return;
      var alt = this.alt;
      if (alt) $(this).after('<span class="caption">' + alt + '</span>');
      $(this).wrap('<a href="' + this.src + '" title="' + alt + '" class="fancybox"></a>');
    });
    $(this).find('.fancybox').each(function(){
      $(this).attr('rel', 'article' + i);
    });
  });
  if($.fancybox){
    $('.fancybox').fancybox();
  }
}); 
</script>



<!-- Analytics Begin -->



<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "//hm.baidu.com/hm.js?e6d1f421bbc9962127a50488f9ed37d1";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>



<!-- Analytics End -->

<!-- Totop Begin -->

	<div id="totop">
	<a title="Back to Top"><img src="/img/scrollup.png"/></a>
	</div>
	<script src="/js/totop.js"></script>

<!-- Totop End -->

<!-- MathJax Begin -->
<!-- mathjax config similar to math.stackexchange -->


<!-- MathJax End -->

<!-- Tiny_search Begin -->

<!-- Tiny_search End -->

  </body>
 </html>
